package com.ld.wms.business.notice.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ld.wms.business.notice.mapper.WarnInfoMapper;
import com.ld.wms.business.notice.model.WarnInfoModel;
import com.ld.wms.business.notice.service.WarnInfoService;
import com.ld.wms.business.notice.vo.resp.WarnInfoRespVo;
import com.ld.wms.common.vo.GeneratePageListVo;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author wangfeng
 * @since 2025-04-23
 */
@Service
public class WarnInfoServiceImpl extends ServiceImpl<WarnInfoMapper, WarnInfoModel> implements WarnInfoService {

    @Autowired
    private WarnInfoMapper warnInfoMapper;

    @Override
    public GeneratePageListVo<WarnInfoRespVo> getPageList(Integer current, Integer size) {
        Page<WarnInfoRespVo> page = new Page<>(current, size);
        IPage<WarnInfoRespVo> warnInfoRespVoIPage = warnInfoMapper.selectPageList(page);
        return new GeneratePageListVo<>(warnInfoRespVoIPage);
    }

    @Override
    public WarnInfoRespVo getById(Long id) {
        WarnInfoRespVo warnInfoRespVo = new WarnInfoRespVo();
        WarnInfoModel warnInfoModel = warnInfoMapper.selectById(id);
        BeanUtils.copyProperties(warnInfoModel, warnInfoRespVo);
        return warnInfoRespVo;
    }


    @Override
    public void warnInIgnore(Long id) {
        WarnInfoModel warnInfoModel = new WarnInfoModel();
        warnInfoModel.setId(id);
        warnInfoModel.setStatus(1);
        warnInfoMapper.updateById(warnInfoModel);
    }
}
